package com.yc.navy.goods.service.lmpl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yc.navy.goods.bean.FindByPageInfo;
import com.yc.navy.goods.bean.OrderInfo;
import com.yc.navy.goods.dto.OrderDTO;
import com.yc.navy.goods.dto.OrderItemInfoListDTO;
import com.yc.navy.goods.dto.OrderItemInfoShopList;
import com.yc.navy.goods.enums.ResultEnum;
import com.yc.navy.goods.mapper.IOrderInfoMapper;
import com.yc.navy.goods.service.IOrderInfoService;
import com.yc.navy.goods.util.FindByPageParamUtil;
import com.yc.navy.goods.util.StringUtil;
import com.yc.navy.goods.vo.StreamVO;

@Service
public class OrderInfoServiceImpl implements IOrderInfoService {
	@Autowired
	private IOrderInfoMapper orderInfoMapper;

	@Override
	public int add(OrderInfo order) {
		if(StringUtil.checkNull(order.getAid(),order.getMid(),order.getTotalprice())) {
			return -1;
		}
		return orderInfoMapper.add(order);
	}

	@Override
	public int findoid(int mid) {
		return orderInfoMapper.findoid(mid);
	}

	@Override
	public int update(Map<String, Object> map) {
		return orderInfoMapper.update(map);
	}

	@Override
	public List<OrderDTO> finds(int mid) {
		return orderInfoMapper.finds(mid);
	}

	@Override
	public StreamVO findList(Map<String, Object> map) {
		List<OrderItemInfoListDTO> list =orderInfoMapper.findList(FindByPageParamUtil.StreamVOfindByPageParam(map));
		if(list.isEmpty() || list.size() <= 0) {
			return new StreamVO(ResultEnum.ERROR);
		}
		return new StreamVO(list,orderInfoMapper.total());
	}

	@Override
	public List<OrderItemInfoShopList> shoperfindList(FindByPageInfo bypage) {
		return orderInfoMapper.shoperfindList(bypage);
	}

	@Override
	public Integer shopertotal(Integer sid) {
		return orderInfoMapper.shopertotal(sid);
	}

	@Override
	public Integer updateOstatus(Integer oid) {
		return orderInfoMapper.updateOstatus(oid);
	}

}
